/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sumvsehchisel;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class SumVsehChisel
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.print("Сумма всех чисел от 1 до ");
        Scanner sc = new Scanner(System.in);
        String value = sc.nextLine();
        int size = Integer.parseInt(value);

        int a = size + 1;
        int b = 0;
        int c = 0;
        int caunter = 000;

        for (int i = 0; i < size; i++)
        {
            a--;
            b++;
            caunter++;

            if (a < b)
            {
                break;
            } else if (a == b)
            {
                c = c + a;
            } else if (a >= 1 && b <= size)
            {
                c = c + (a + b);
            }

//            System.out.printf("№%d |A+B| |%d+%d| ",caunter, a, b);
//            System.out.printf(" C = %d\n", c);
        }
        System.out.printf("Сумма равна = %d\n", c);
    }
}
